#include <iostream>
#include <vector>

using namespace std;
/**
 * @brief
 * 1 <= s.length <= 1000
 * s[i] is either 'A', 'L', or 'P'.
 */
class Solution
{
public:
    bool checkRecord(string s)
    {
        int tempA = 0, sLen = s.length();
        for (int i = 0; i < sLen; ++i)
        {
            if ('A' == s[i])
            {
                tempA++;
            }
            if ('L' == s[i])
            {
                if (i + 1 < sLen && 'L' == s[i + 1] && i + 2 < sLen && 'L' == s[i + 2])
                {
                    return false;
                }
            }
            if (2 == tempA)
            {
                return false;
            }
        }
        return true;
    }
    bool checkRecord_2(string s)
    {
        return (s.find("LLL") == string::npos) && (s.find('A') == s.rfind('A'));
    }
};
int main()
{
    Solution s;
    string str = "PPALLL";
    cout << s.checkRecord(str) << endl;
    system("pause");
    return 0;
}
